<template>
  <div>
    <h1>蔬菜组件</h1>
    <div>
      <h2>菜单</h2>
      <div v-for="item in lists" :key="item.sid">
        今日标题：{{ item.name }} - 发布时间： {{ item.passtime }}
      </div>
      <button @click="getTa">查看</button>
    </div>
  </div>
</template>

<script>
import { FetchShucai } from "@api/getTest.js";
export default {
  data() {
    return {
      lists: [],
    };
  },
  created() {
    // 请求数据
    console.log("Shucai的craeted");
    this.FetchShucai();
  },
  activated() {
    console.log("激活显示");
  },
  deactivated() {
    console.log("禁用隐藏");
  },
  methods: {
    async FetchShucai() {
      //    let data = await this.$axios.get("https://api.apiopen.top/getJoke?page=1&count=2&type=video")
      let data = await FetchShucai();
      console.log(data);
      this.lists = data.result;
    },
    async getTa() {
      let { data } = await this.$httpGet(
        "https://api.apiopen.top/getSingleJoke?sid=28654780"
      );
      console.log(data);
    },
  },
};
</script>

<style lang="scss" scoped></style>
